//# sourceURL=http://uMapApp/App
define([
    "mhjs/mhjs",
    "uMap/uMap",
    "uEarth/uEarth",
    "Cesium/Mixin/viewerCesiumNavigationMixin.min",
    "./Earth/EarthSetting",
    "./Earth/DataSource/DataSource",
    "./UI/Layer",
    "./UI/Panel/TopPanel",
    "./UI/Panel/BottomPanel",
    "./UI/Panel/PositionPopPanel",
    "./UI/TopMenu/TopMenus",
    "./Module/HomeModule/HomeModule",
    "./Module/RoadModule",
    "./Module/PQI/PQIStaModule",
    "./Module/Maintain/MaintainStaModule",
    "./Module/Bridge/BridgeProfileModule",
    "./Module/Bridge/BridgeDetectionModule",
    "./Module/Camera/CameraModule",
    "./Module/Camera/CameraBridgeModule",
    "./Module/InspectionModule/InspectionModule",
    "./Module/UavFlight/UavFlightsModule",
    "./Module/EventAlert/EventAlertModule",
    "./Module/SettingsModule"
    , "./Module/ToolModule"
    , "./UI/QueryManager"
    , "./UI/QueryNode"
    , "./UI/SplineDrawer"
    , "./UI/ModalityWindow"
    , "./UI/Panel/FloatPanel"
    , "./UI/Checkbox"
    , "./Module/StakeNum/Mileage"
], function (
    mhjs,
    uMap,
    uEarth,
    viewerCesiumNavigationMixin,
    EarthSetting,
    DataSource,
    Layer,
    TopPanel,
    BottomPanel,
    PositionPopPanel,
    TopMenus,
    HomeModule,
    RoadModule,
    PQIStaModule,
    MaintainStaModule,
    BridgeProfileModule,
    BridgeDetectionModule,
    CameraModule,
    CameraBridgeModule,
    InspectionModule,
    UavFlightsModule,
    EventAlertModule,
    SettingsModule
    , ToolModule
    , QueryManager
    , QueryNode
    , SplineDrawer
    , ModalityWindow
    , FloatPanel
    , Checkbox
    , Mileage
) {

    function App(option) {

        var _this = this;

        mhjs.Div.call(_this, option);
        _this.addClass("uMapApp");
        _this.addClass("app");

        _this.queryManager = new QueryManager();
        _this.append(_this.queryManager.modalityLoading);
        _this.queryManager.open();

        //地球布局
        _this.layoutInit();

        //三维容器
        _this.earthInit();

        //调试参数
        _this.debugInit();

        //全局接口
        _this.load(function () {

            //全局影像加载
            _this.earth.imageryLayers.raiseToTop(_this.layers.GIS.IMAGERY.GLOBE_OVERLAY.dataSourceView.imagery.object);
            _this.layers.GIS.IMAGERY.GLOBE.open();
            _this.layers.GIS.IMAGERY.GLOBE_OVERLAY.open();
            // _this.layers.GIS.IMAGERY.ROAD.open();

            //全局地形加载
            // _this.layers.GIS.TERRAIN.GLOBE.open();

            //全线模型加载
            // _this.layers.GIS.C3DTILE.G50.open();


            _this.main3DLayer = _this.layers.GIS.C3DTILE["G50-2020"];
            _this.main3DLayer.open();


            _this.globeImage = _this.layers.GIS.IMAGERY.GLOBE;
            _this.globeImageOverlay = _this.layers.GIS.IMAGERY.GLOBE_OVERLAY;

            _this.globeMap = _this.layers.GIS.IMAGERY.GLOBE_MAP;
            _this.globeMapOverlay = _this.layers.GIS.IMAGERY.GLOBE_MAP_OVERLAY;

            //ui组件
            _this.elementInit();

            //功能组件
            _this.moduleInit();


            //顶部菜单与模块绑定
            _this.ui.elements.topPanel.menus = new TopMenus({
                "app" : _this,
                "list": [
                    {
                        "autoLoad": true,
                        "module"  : _this.modules.eventAlert
                    },
                    {
                        "module": _this.modules.home
                    },
                    {
                        "module": _this.modules.road
                    },
                    {
                        "module": _this.modules.PQI
                    },
                    {
                        "module": _this.modules.maintain
                    },
                    {
                        "module": _this.modules.bridgeProfile
                    },
                    {
                        "module": _this.modules.bridgeDetection
                    },
                    {
                        "module": _this.modules.cameraBridge
                    },
                    {
                        "module": _this.modules.camera
                    },
                    {
                        "module": _this.modules.inspection
                    },
                    {
                        "module": _this.modules.UAVFlight
                    },
                    {
                        "module": _this.modules.settings
                    },
                    {
                        "module": _this.modules.tool
                    },
                    {
                        "label": "管理后台",
                        "name" : "admin",
                        "icon" : _this.icons.admin
                    },
                    {
                        "label": "全屏展示",
                        "name" : "fullscreen",
                        "icon" : _this.icons.fullscreen
                    },
                    {
                        "label": "退出系统",
                        "name" : "logout",
                        "icon" : _this.icons.logout
                    }
                ]
            });

            _this.ui.elements.topPanel.menus.fullscreen.isFullscreen = false;
            _this.ui.elements.topPanel.menus.fullscreen.on("click", function (menu) {

                if (menu.isFullscreen) {
                    mhjs.FullScreen.exit();
                    menu.isFullscreen = false;
                } else {
                    mhjs.FullScreen.enter();
                    menu.isFullscreen = true;
                }

            });

            _this.ui.elements.topPanel.menus.admin.on("click", function (menu) {
                window.open(_this.servers.DC.adminURL);
            });

            _this.ui.elements.topPanel.menus.logout.on("click", function (menu) {
                _this.servers.DC.requests.logout.send({}, function (json) {
                    window.location.href = json.mess;
                });
            });

            _this.ui.elements.topPanel.append(_this.ui.elements.topPanel.menus);

            _this.tempRun();


            //进入动画
            _this.start(function () {
                if (!_this.ui.elements.topPanel.menus.activeMenu) {
                    _this.modules.home.menu.trigger("click");
                }
            });


        });

    }

    var _class = App;

    mhjs.Inherit(_class, mhjs.Div);

    Object.defineProperties(_class.prototype, {
        "flyHome"        : {
            value: function (pitch, duration, completeFunction) {
                this.earth.camera.flyToBoundingSphere(
                    new uEarth.BoundingSphere(
                        uEarth.Cartesian3.fromDegrees(
                            this.center.position.longitude,
                            this.center.position.latitude,
                            0
                        ),
                        this.center.camera.distance
                    ),
                    {
                        offset  : new uEarth.HeadingPitchRange(
                            uEarth.Math.toRadians(this.center.camera.heading),
                            uEarth.Math.toRadians(pitch ? this.center.camera.pitchFinal : this.center.camera.pitch),
                            this.center.camera.distance
                        ),
                        duration: duration || 5,
                        complete: completeFunction
                    });
            }
        },
        "startFly"       : {
            value: function (completeFunction) {

                var _this = this;

                _this.earth.camera.flyToBoundingSphere(
                    new uEarth.BoundingSphere(
                        uEarth.Cartesian3.fromDegrees(
                            _this.center.position.longitude,
                            _this.center.position.latitude,
                            0
                        ),
                        _this.center.camera.distance
                    ),
                    {
                        offset  : new uEarth.HeadingPitchRange(
                            uEarth.Math.toRadians(_this.center.camera.heading),
                            uEarth.Math.toRadians(_this.center.camera.pitch),
                            _this.center.camera.distance
                        ),
                        duration: _this.startFlyTime || 1,
                        // easingFunction: uEarth.EasingFunction.SINUSOIDAL_IN,
                        complete: function () {
                            _this.flyHome(true, 3, completeFunction);
                        }
                    });
            }
        },
        "flyVP"          : {
            value: function (viewport) {

                var _this = this;

                var localvp = {
                    "center": {
                        "longitude": (viewport && viewport.center && viewport.center.longitude) || 0,
                        "latitude" : (viewport && viewport.center && viewport.center.latitude) || 0,
                        "height"   : (viewport && viewport.center && viewport.center.height) || 0
                    },
                    "hpr"   : {
                        "heading": (viewport && viewport.hpr && viewport.hpr.heading) || 0,
                        "pitch"  : (viewport && viewport.hpr && viewport.hpr.pitch) || -90,
                        "range"  : (viewport && viewport.hpr && viewport.hpr.range) || 100
                    }
                };

                _this.earth.camera.flyToBoundingSphere(
                    new uEarth.BoundingSphere(new uEarth.Cartesian3.fromDegrees(
                        localvp.center.longitude,
                        localvp.center.latitude,
                        localvp.center.height
                    ), localvp.hpr.range),
                    {
                        offset: new uEarth.HeadingPitchRange(
                            uEarth.Math.toRadians(localvp.hpr.heading),
                            uEarth.Math.toRadians(localvp.hpr.pitch),
                            localvp.hpr.range
                        )
                    });
            }
        },
        "flyViewportKeep": {
            value: function (viewport) {

                var _this = this;

                var currentViewport = _this.earth.getCameraViewport();

                var heading = 0;
                var pitch = -90;
                var range = 1000;

                if (viewport.getChainChild("hpr.heading") !== undefined) {
                    heading = viewport.getChainChild("hpr.heading");
                } else if (currentViewport.getChainChild("hpr.heading")) {
                    heading = currentViewport.getChainChild("hpr.heading");
                }

                if (viewport.getChainChild("hpr.pitch") !== undefined) {
                    pitch = viewport.getChainChild("hpr.pitch");
                } else if (currentViewport.getChainChild("hpr.pitch")) {
                    pitch = currentViewport.getChainChild("hpr.pitch");
                }

                range = viewport.getChainChild("hpr.range") || currentViewport.getChainChild("hpr.range") || range;

                _this.earth.camera.flyToBoundingSphere(
                    new uEarth.BoundingSphere(new uEarth.Cartesian3.fromDegrees(
                        viewport.center.longitude,
                        viewport.center.latitude,
                        viewport.center.height
                    ), range),
                    {
                        offset       : new uEarth.HeadingPitchRange(
                            uEarth.Math.toRadians(heading),
                            uEarth.Math.toRadians(pitch),
                            range
                        ),
                        maximumHeight: range * Math.cos(Math.abs(pitch))
                    });
            }
        },
        "layoutInit"     : {
            value: function () {

                var _this = this;

                var queryNode = _this.queryManager.add(new QueryNode({
                    "title"   : "[初始化] : 布局",
                    "modality": true
                }));

                queryNode.trigger("send");

                //布局
                _this.ui = {};
                _this.ui.layout = {};

                //基本布局容器
                _this.ui.layout.left = new mhjs.Div({"class": "uMapApp_left"});
                _this.ui.layout.right = new mhjs.Div({"class": "uMapApp_right"});
                _this.ui.layout.top = new mhjs.Div({"class": "uMapApp_top"});
                _this.ui.layout.bottom = new mhjs.Div({"class": "uMapApp_bottom"});

                //顶层容器
                _this.ui.layout.appOverlay = new mhjs.Div({"class": "uMapApp_appOverlay"});
                //地球容器
                _this.ui.layout.earthOverlay = new mhjs.Div({"class": "uMapApp_earthOverlay"});

                //视图中心
                _this.center = {
                    "position": {
                        "longitude": 120.67130209772846, "latitude": 30.99069307499852, "height": 0
                    },
                    "camera"  : {
                        "heading"   : 0,
                        "pitch"     : -90,
                        "pitchFinal": -90,
                        "distance"  : 1e5
                    }
                };

                //绘制地球需要加载到页面上,所以先加载
                $("body").append(_this.dom);

                //地球容器
                _this.ui.layout.earthContainer = new mhjs.Div({
                    "class": "uMapApp_earthContainer",
                    "id"   : "uMapApp_earthContainer"
                });
                _this.append(_this.ui.layout.earthContainer);

                //布局绘制
                _this
                    .append(_this.ui.layout.bottom
                    )
                    .append(_this.ui.layout.right
                    )
                    .append(_this.ui.layout.top
                    )
                    .append(_this.ui.layout.left
                    )
                    .append(_this.ui.layout.earthOverlay
                    )
                    .append(_this.ui.layout.appOverlay
                    );

                queryNode.trigger("loaded");


                // console.log("[初始化] : 布局 > 完成");
            }
        },
        "earthInit"      : {
            value: function () {

                var _this = this;

                var queryNode = _this.queryManager.add(new QueryNode({
                    "title": "[初始化] : 地球"
                }));

                queryNode.trigger("send");

                _this.earth = new uMap.Earth({
                    objectOption: {
                        "container": _this.ui.layout.earthContainer.id
                    }
                });

                _this.earth.scene.globe.depthTestAgainstTerrain = true;

                //导航罗盘
                _this.earth.extend(viewerCesiumNavigationMixin, {
                    defaultResetView      : uEarth.Rectangle.fromDegrees(-60, 0, -90, 70),
                    enableCompass         : true,
                    enableZoomControls    : false,
                    enableDistanceLegend  : false,
                    enableCompassOuterRing: true
                });

                //地球设置
                _this.earth.setting = new EarthSetting(_this.earth, {
                    isImageryShow         : true
                    , isTerrainShow       : false
                    , isShowSun           : true
                    , isShowSky           : true
                    , isShowAtmosphere    : true
                    , isShowGridImagery   : false
                    , isShowCompass       : true
                    , isShowDistanceLegend: true
                    , isHighResolution    : false
                    , isOpenFxaa          : true
                    , isShowShadow        : false
                    , isFixedTime         : true
                });

                _this.earth.on("click", function () {
                    console.info("[调试]:当前视角 > ");
                    console.log(JSON.stringify(_this.earth.getCameraViewport()));
                });

                _this.pop = new PositionPopPanel({showClose: true, earth: _this.earth});

                _this.pop.on("close", function (pop) {
                    pop.target = undefined;
                });
                _this.ui.layout.earthOverlay.append(_this.pop);

                _this.speaker = new mhjs.Speaker();

                _this.videoPlayer = new uMap.VideoPlayer();
                _this.ui.layout.earthOverlay.append(_this.videoPlayer);

                _this.modalityWindow = new ModalityWindow();
                _this.ui.layout.appOverlay.append(_this.modalityWindow);


                //界面自适应
                _this.designSize = {
                    width : 1600,
                    height: 960
                };

                _this.fitSize = function () {
                    var target = mhjs.WindowSize.getScaleSize(_this.designSize);
                    _this.scale = target.r;

                    if (_this.scale > 0.5 && this.scale < 2) {
                        _this.css({
                            "transform": "scale(" + target.r + ")",
                            "width"    : target.w,
                            "height"   : target.h
                        });

                        $(_this.earth.canvas).css({
                            "transform": "scale(" + 1 / target.r + ")"
                        });
                    }
                };

                _this.fitSize();

                window.onresize = function (ev) {
                    _this.fitSize();
                };


                //摄像头控制

                // var minPitch = -uEarth.Math.PI_OVER_TWO;
                // var maxPitch = 10;
                // var minHeight = 50;
                //
                // _this.earth.camera.changed.addEventListener(function () {
                //     _this.ui.infoBar.positionInfo.heightInfo.valueText.text(distanceText(new uMap.Position(_this.earth.camera.position).lnglat.height));
                //
                //     //禁止镜头朝上
                //     if (_this.earth.camera._suspendTerrainAdjustment && _this.earth.scene.mode === uEarth.SceneMode.SCENE3D) {
                //         _this.earth.camera._suspendTerrainAdjustment = false;
                //         _this.earth.camera._adjustHeightForTerrain();
                //     }
                //
                //     //禁止镜头朝上
                //     var pitch = _this.earth.camera.pitch;
                //
                //     if (_this.earth.camera.positionCartographic.height < minHeight) {
                //         if (pitch > maxPitch || pitch < minPitch) {
                //             _this.earth.scene.screenSpaceCameraController.enableTilt = false;
                //
                //             // clamp the pitch
                //             if (pitch > maxPitch) {
                //                 pitch = maxPitch;
                //             } else if (pitch < minPitch) {
                //                 pitch = minPitch;
                //             }
                //
                //             var destination = uEarth.Cartesian3.fromRadians(
                //                 _this.earth.camera.positionCartographic.longitude,
                //                 _this.earth.camera.positionCartographic.latitude,
                //                 _this.earth.camera.positionCartographic.height);
                //
                //             _this.earth.camera.setView({
                //                 destination: destination,
                //                 orientation: {pitch: pitch}
                //             });
                //             _this.earth.scene.screenSpaceCameraController.enableTilt = true;
                //         }
                //     }
                // });

                // _this.earth.camera.changed.addEventListener(function () {
                //     _this.pop.close();
                // });

                queryNode.trigger("loaded");

            }
        },
        "debugInit"      : {
            value: function () {

                var _this = this;

                var queryNode = _this.queryManager.add(new QueryNode({
                    "title": "[初始化] : 调试"
                }));

                queryNode.trigger("send");

                _this.debug = {};

                _this.debug.isDebug = true;
                _this.debug.debugTransform = false;

                _this.debug.transformPanel = new uMap.TransformPanel({
                    "earth"     : _this.earth,
                    "title"     : "模型位置调整",
                    "showClose" : true,
                    "showSubmit": true,
                    "submitText": "复制变形参数到剪贴板"
                });

                _this.debug.transformPanel.on("submit", function (panel) {
                    uMap.Clipboard(panel.transform.value);
                });


                // _this.debug.isDebug = mhjs.Url.getQueryString("debug");
                _this.ui.layout.left.append(_this.debug.transformPanel);

                if (_this.debug.isDebug) {
                    _this.startPause = 0;
                    _this.startFlyTime = 0;
                } else {
                    _this.startPause = 1000;
                    _this.startFlyTime = 5;
                }

                queryNode.trigger("loaded");

            }
        },
        "load"           : {
            value: function (callback) {

                var _this = this;

                var queryNode = _this.queryManager.add(new QueryNode({
                    "title": "[初始化] : 数据"
                }));

                queryNode.trigger("send");

                _this.iconInit(function () {

                    _this.query = new mhjs.Query();
                    _this.query.on("loaded", function () {
                        queryNode.trigger("loaded");
                        callback && callback();
                    });

                    $.get("./data/servers.json").done(function (json) {

                        _this.servers = {};
                        _this.dataSources = {};
                        _this.layers = {};

                        $.each(json.servers, function (i, serverJson) {
                            var server = new mhjs.Server(serverJson);
                            _this.servers[server.name] = server;
                        });

                        // if (_this.servers.DC) {
                        //     _this.query.add(_this.servers.DC.requests.login);
                        //     _this.servers.DC.requests.login.send({}, function (json) {
                        //         _this.servers.DC.accessToken = json.data.accessToken;
                        //     });
                        // }

                        if (_this.servers.GIS) {
                            _this.preloadServer(_this.servers.GIS);
                        }
                    });

                });


            }
        },
        "preloadServer"  : {
            value: function (server) {

                var _this = this;


                _this.dataSources[server.name] = {};
                _this.layers[server.name] = {};

                $.each(server.requests, function (j, request) {

                    _this.dataSources[server.name][request.name] = {};
                    _this.layers[server.name][request.name] = {};
                    _this.query.add(request);

                    var queryNode = _this.queryManager.add(new QueryNode({"request": request}));

                    request.send({}, function (json) {

                        $.each(json.data.list, function (i, dataSourceJson) {

                            var dataSource = new DataSource(dataSourceJson);

                            _this.dataSources[server.name][request.name][dataSourceJson.name] = dataSource;
                            _this.layers[server.name][request.name][dataSourceJson.name] = new Layer({
                                "dataSource": dataSource,
                                "app"       : _this,
                                "debug"     : dataSource.debug
                            });

                            // console.log(server.name + " > " + request.name + " > " + dataSourceJson.name);

                        });

                    });
                });
            }
        },
        "start"          : {
            value: function (after) {

                var _this = this;
                setTimeout(function () {
                    _this.startFly(function () {
                        after();
                    });
                }, _this.startPause);
            }
        },
        "elementInit"    : {
            value: function () {

                var _this = this;

                var queryNode = _this.queryManager.add(new QueryNode({
                    "title": "[初始化] : 界面"
                }));

                queryNode.trigger("send");

                //界面元素
                _this.ui.elements = {};

                _this.ui.elements.topPanel = new TopPanel({
                    "title": "智慧工区综管平台",
                    "app"  : _this
                });
                _this.ui.layout.top.append(_this.ui.elements.topPanel);

                _this.ui.elements.bottomPanel = new BottomPanel({
                    "app"      : _this,
                    "copyright": "智慧工区综管平台 ©2022"
                });


                _this.ui.elements.bottomPanel.append(_this.queryManager);

                _this.ui.layout.bottom.append(_this.ui.elements.bottomPanel);

                _this.earth.on("mouseOver", function (position) {
                    _this.ui.elements.bottomPanel.position = new uMap.Position({
                        longitude: position.stopPosition.lnglat.longitude,
                        latitude : position.stopPosition.lnglat.latitude,
                        height   : new uMap.Position(_this.earth.camera.position).lnglat.height
                    });
                });

                _this.ui.elements.tileSwitchPanel = new FloatPanel({"class": "tileSwitchPanel"});

                _this.ui.elements.tileSwitchPanel.tileSwitch = new Checkbox({
                    "class": "switch"
                });
                _this.ui.elements.tileSwitchPanel.tileSwitch.label = "环境三维";

                if (_this.main3DLayer) {
                    if (_this.main3DLayer.isOpened) {
                        _this.ui.elements.tileSwitchPanel.tileSwitch.isChecked = true;
                    }
                }

                _this.ui.elements.tileSwitchPanel.tileSwitch.on("change", function (checkbox) {
                    if (checkbox.isChecked) {
                        _this.main3DLayer && _this.main3DLayer.open();
                    } else {
                        _this.main3DLayer && _this.main3DLayer.close();
                    }
                });

                _this.ui.elements.tileSwitchPanel.append(_this.ui.elements.tileSwitchPanel.tileSwitch);


                _this.ui.elements.tileSwitchPanel.dimensionSwitch = new Checkbox({
                    "class": "switch"
                });
                _this.ui.elements.tileSwitchPanel.dimensionSwitch.label = "二维模式";

                _this.ui.elements.tileSwitchPanel.dimensionSwitch.on("change", function (checkbox) {

                    if (checkbox.isChecked) {
                        _this.earth.scene.mode = 2;

                        _this.globeImage.close();
                        _this.globeImageOverlay.close();
                        _this.globeMap.open();
                        _this.globeMapOverlay.open();

                        _this.ui.elements.tileSwitchPanel.tileSwitch.isChecked = false;
                        _this.ui.elements.tileSwitchPanel.tileSwitch.isEnabled = false;
                    } else {
                        _this.earth.scene.mode = 3;

                        _this.globeImage.open();
                        _this.globeImageOverlay.open();
                        _this.globeMap.close();
                        _this.globeMapOverlay.close();

                        _this.ui.elements.tileSwitchPanel.tileSwitch.isChecked = true;
                        _this.ui.elements.tileSwitchPanel.tileSwitch.isEnabled = true;

                    }
                });

                _this.ui.elements.tileSwitchPanel.append(_this.ui.elements.tileSwitchPanel.dimensionSwitch);

                _this.ui.layout.bottom.append(_this.ui.elements.tileSwitchPanel);
                _this.ui.elements.tileSwitchPanel.open();

                queryNode.trigger("loaded");
            }
        },
        "iconInit"       : {
            value: function (callback) {

                var _this = this;

                _this.icons = {};

                var queryNode = _this.queryManager.add(new QueryNode({
                    "title": "[初始化] : 图标缓存"
                }));

                queryNode.trigger("send");

                $.get("./data/icons.json").done(function (json) {

                    var toload = 0;

                    $.each(json, function (i, icon) {
                        toload++;
                    });

                    $.each(json, function (i, icon) {
                        mhjs.Tool.loadImg(icon, function (img) {
                            _this.icons[i] = {
                                base64: mhjs.Tool.getBase64Image(img),
                                img   : img
                            };
                            toload--;
                            if (toload === 0) {

                                _this.icons.getIconMarker = function (icon, active) {

                                    if (active) {
                                        return mhjs.Tool.combineImg(_this.icons.marker_active.img, icon.img, 12, 6);
                                    } else {
                                        return mhjs.Tool.combineImg(_this.icons.marker.img, icon.img, 12, 6);
                                    }


                                };

                                callback && callback();
                            }
                        });
                    });

                    queryNode.trigger("loaded");

                });

            }
        },
        "moduleInit"     : {
            value: function () {

                var _this = this;

                var queryNode = _this.queryManager.add(new QueryNode({
                    "title": "[初始化] : 模块"
                }));

                queryNode.trigger("send");

                _this.modules = {};

                _this.modules.road = new RoadModule({"app": _this});
                _this.modules.PQI = new PQIStaModule({
                    "app"           : _this,
                    "historyRequest": _this.servers.DC.requests.road_pqi_history,
                    "request"       : _this.servers.DC.requests.road_pqi_statistics,
                    "map"           : _this.servers.DC.requests.road_pqi_statistics_map,
                    "dic"           : _this.servers.DC.requests.road_pqi_dic_map
                });
                _this.modules.maintain = new MaintainStaModule({
                    "app"              : _this,
                    "request"          : _this.servers.DC.requests.road_maintenance,
                    "damageTypeRequest": _this.servers.DC.requests.damage_type,
                    "map"              : _this.servers.DC.requests.road_maintenance_map
                });

                _this.modules.bridgeProfile = new BridgeProfileModule({
                    "app"                    : _this,
                    "request"                : _this.servers.DC.requests.bridge,
                    "map"                    : _this.servers.DC.requests.bridge_map,
                    "bridgePropertiesRequest": _this.servers.DC.requests.bridge_properties,
                    "fileTreeRequest"        : _this.servers.DC.requests.bridge_file_tree,
                    "bridgeFileRequest"      : _this.servers.DC.requests.bridge_file_bridge_name
                });

                _this.modules.bridgeDetection = new BridgeDetectionModule({
                    "app"    : _this,
                    "request": _this.servers.DC.requests.bridge_detection,
                    "map"    : _this.servers.DC.requests.bridge_detection_map,
                    "node"   : {
                        "request"    : _this.servers.DC.requests.bridge_detection_node,
                        "dataRequest": _this.servers.DC.requests.bridge_detection_node_data,
                        "map"        : _this.servers.DC.requests.bridge_detection_node_map
                    }
                });

                _this.modules.camera = new CameraModule({
                    "request"   : _this.servers.DC.requests.camera,
                    "map"       : _this.servers.DC.requests.camera_map,
                    "app"       : _this,
                    "standalone": true
                });

                _this.modules.cameraBridge = new CameraBridgeModule({
                    "request"        : _this.servers.DC.requests.camera_bridge,
                    "map"            : _this.servers.DC.requests.camera_bridge_map,
                    "positionRequest": _this.servers.DC.requests.camera_bridge_position,
                    "app"            : _this,
                    "standalone"     : true
                });

                _this.modules.UAVFlight = new UavFlightsModule({
                    "request": _this.servers.DC.requests.UAVvideo,
                    "app"    : _this
                });

                _this.modules.eventAlert = new EventAlertModule({
                    "request"        : _this.servers.DC.requests.eventAlert,
                    "positionRequest": _this.servers.DC.requests.camera_bridge_position,
                    "map"            : _this.servers.DC.requests.eventAlert_map,
                    "app"            : _this
                });


                _this.modules.inspection = new InspectionModule({"app": _this});
                _this.modules.settings = new SettingsModule({"app": _this});

                _this.modules.home = new HomeModule({"app": _this});

                _this.modules.tool = new ToolModule({"app": _this});

                queryNode.trigger("loaded");

            }
        },
        "tempRun"        : {
            value: function () {
                var _this = this;

            }
        }
    });

    return _class;

});